/**
 * Copyright (c) 2017-2022 Rushang Co.Ltd All Rights Reserved.
 */
package com.rshang.rsdp.controller;


import com.rshang.rsdp.bean.DataGrid;
import com.rshang.rsdp.bean.Response;
import com.rshang.rsdp.service.ITbUserService;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * 功能简介：用户数据处理api<br/>
 *
 * @author zhangjun
 * @create 2017年7月20日下午4:48:28
 */
@Controller
@RequiresRoles("管理员")
@RequestMapping("/system/user")
public class UserController extends BaseController {

    @Autowired
    ITbUserService service;


    @RequestMapping("/addSave")
    @ResponseBody
    public Response addSave() {
        return service.addSave(request, this.getSessionUser().getUserId());
    }

    @RequestMapping("/editSave")
    @ResponseBody
    public Response editSave() {
        return service.editSave(request, this.getSessionUser().getUserId());
    }

    @RequestMapping("/checkUserName")
    @ResponseBody
    public Response checkUserName() {
        return service.checkUserName(request);
    }

    @RequestMapping("/delete")
    @ResponseBody
    public Response delete() {
        return service.deleteUser(request, this.getSessionUser().getUserId());
    }

    @RequestMapping("/initPwd")
    @ResponseBody
    public Response initPwd() {
        return service.initPwd(request, this.getSessionUser().getUserId());
    }

    @ResponseBody
    @RequestMapping("/manage")
    public DataGrid manage(HttpServletRequest request) {
        return service.getUserPageList(getPage(), request);
    }


}
